package kosta.service;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import kosta.model.dao.AuctionDAO;
import kosta.model.dao.NoticeDAO;
import kosta.model.vo.ListVO;
import kosta.model.vo.NoticeVO;
import kosta.model.vo.PagingBean;
import kosta.model.vo.SearchVO;

import org.springframework.stereotype.Service;

@Service
public class NoticeServiceImpl implements NoticeService{
	
	@Resource(name="auctionDAOImpl")
	private AuctionDAO auctionDAO;
	@Resource(name="noticeDAOImpl")
	private NoticeDAO noticeDAO;
	
	@Override
	public HashMap<String, List> getMainInfoList() {
		 List mainAuctionList = auctionDAO.getMainAuctionList();
		 List mainNoticeList = noticeDAO.getMainNoticeList();
		 HashMap<String, List> map = new HashMap();
		 map.put("mainAuctionList", mainAuctionList);
		 map.put("mainNoticeList", mainNoticeList);		 
		return map;	
	}

	@Override
	public NoticeVO showNoticeContent(String noticeNo) {
		noticeDAO.updateHits(noticeNo);
		return noticeDAO.showNoticeContent(noticeNo);
	}

	@Override
	public NoticeVO showNoticeContentNotHit(String noticeNo) {		
		return noticeDAO.showNoticeContent(noticeNo);
	}

	@Override
	public ListVO getNoticeBoardList(SearchVO svo) {
		int total=noticeDAO.noticePageCount(svo);
	
		List list=noticeDAO.getNoticeBoardList(svo);		

		PagingBean pagingBean=new PagingBean(total,svo.getPageNo());
	
		return new ListVO(list,pagingBean);
	}

	@Override
	public void writeNotice(NoticeVO nvo) {
		System.out.println("(Service)공지사항 글쓰기"+nvo);
		noticeDAO.writeNotice(nvo);
	}

	@Override
	public void deleteNotice(String noticeNo) {
		System.out.println("(Service)공지사항 삭제"+noticeNo);
		noticeDAO.deleteNotice(noticeNo);
	}

	@Override
	public void updateNotice(NoticeVO nvo) {
		System.out.println("(Service)공지사항 수정"+nvo);
		 noticeDAO.updateNotice(nvo);
	}

}
